from django import newforms as forms
from pollster.models import *

class PollForm(forms.Form):
	
	choices = forms.ModelChoiceField(queryset=Choice.objects.all(), widget=forms.RadioSelect, empty_label=None)
	poll = forms.CharField(widget=forms.HiddenInput)
	
	def __init__(self, poll, *args, **kwargs):
		self.poll = poll
		self.base_fields['choices'].queryset = poll.choice_set.all()
		self.base_fields['choices'].label = poll.question
		self.base_fields['poll'].initial = poll.id
		forms.Form.__init__(self, *args, **kwargs)